package com.bos.dao.impl;

import com.bos.dao.KelurahanDAO;
import com.bos.domain.Kecamatan;
import com.bos.domain.Kelurahan;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Latief
 * Date: 3/15/11
 * Time: 9:29 PM
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class KelurahanDAOImpl extends GenericDAOImpl<Kelurahan> implements KelurahanDAO {

    public KelurahanDAOImpl() {
        super(Kelurahan.class);
    }

    public List<Kelurahan> getByKecamatan(Kecamatan kecamatan) throws DataAccessException {
//       entityManager.clear();
       return entityManager.createQuery("select obj from " + type.getName() + " obj where obj.kecamatan = :kecamatan")
               .setParameter("kecamatan", kecamatan)
               .getResultList();
   }
}
